package com.vaadin.incubator.bugrap.tests.model;

import java.util.Date;

import org.junit.Test;

import com.vaadin.incubator.bugrap.model.facade.FacadeUtil;
import com.vaadin.incubator.bugrap.model.projects.Project;
import com.vaadin.incubator.bugrap.model.projects.ProjectVersion;
import com.vaadin.incubator.bugrap.model.reports.Report;
import com.vaadin.incubator.bugrap.model.reports.ReportPriority;
import com.vaadin.incubator.bugrap.model.reports.ReportResolution;
import com.vaadin.incubator.bugrap.model.reports.ReportStatus;
import com.vaadin.incubator.bugrap.model.reports.ReportType;
import com.vaadin.incubator.bugrap.model.users.Reporter;

public class ReportTest extends TestBase {

	@Test
	public void testGetType() {
		Report r = new Report();
		r.setType(ReportType.BUG);
		r = FacadeUtil.store(r);
		assertEquals(ReportType.BUG, r.getType());
	}

	@Test
	public void testSetType() {
		Report r = new Report();
		r.setType(ReportType.BUG);
		r = FacadeUtil.store(r);
		assertEquals(ReportType.BUG, r.getType());
	}

	@Test
	public void testGetSummary() {
		Report r = new Report();
		r.setSummary("sum");
		r = FacadeUtil.store(r);
		assertEquals("sum", r.getSummary());
	}

	@Test
	public void testSetSummary() {
		Report r = new Report();
		r.setSummary("sum");
		r = FacadeUtil.store(r);
		assertEquals("sum", r.getSummary());
	}

	@Test
	public void testGetDescription() {
		Report r = new Report();
		r.setDescription("descr");
		r = FacadeUtil.store(r);
		assertEquals("descr", r.getDescription());
	}

	@Test
	public void testSetDescription() {
		Report r = new Report();
		r.setDescription("descr");
		r = FacadeUtil.store(r);
		assertEquals("descr", r.getDescription());
	}

	@Test
	public void testGetProject() {
		Project p = new Project();
		p = FacadeUtil.store(p);

		Report r = new Report();
		r.setProject(p);
		r = FacadeUtil.store(r);
		assertEquals(p, r.getProject());
	}

	@Test
	public void testSetProject() {
		Project p = new Project();
		p = FacadeUtil.store(p);

		Report r = new Report();
		r.setProject(p);
		r = FacadeUtil.store(r);
		assertEquals(p, r.getProject());
	}

	@Test
	public void testGetVersion() {
		ProjectVersion v = new ProjectVersion();
		v = FacadeUtil.store(v);

		Report r = new Report();
		r.setVersion(v);
		r = FacadeUtil.store(r);
		assertEquals(v, r.getVersion());
	}

	@Test
	public void testSetVersion() {
		ProjectVersion v = new ProjectVersion();
		v = FacadeUtil.store(v);

		Report r = new Report();
		r.setVersion(v);
		r = FacadeUtil.store(r);
		assertEquals(v, r.getVersion());
	}

	@Test
	public void testGetPriority() {
		Report r = new Report();
		r.setPriority(ReportPriority.BLOCKER);
		r = FacadeUtil.store(r);
		assertEquals(ReportPriority.BLOCKER, r.getPriority());
	}

	@Test
	public void testSetPriority() {
		Report r = new Report();
		r.setPriority(ReportPriority.BLOCKER);
		r = FacadeUtil.store(r);
		assertEquals(ReportPriority.BLOCKER, r.getPriority());
	}

	@Test
	public void testGetAssigned() {
		Reporter u = new Reporter();
		u = FacadeUtil.store(u);

		Report r = new Report();
		r.setAssigned(u);
		r = FacadeUtil.store(r);
		assertEquals(u, r.getAssigned());
	}

	@Test
	public void testSetAssigned() {
		Reporter u = new Reporter();
		u = FacadeUtil.store(u);

		Report r = new Report();
		r.setAssigned(u);
		r = FacadeUtil.store(r);
		assertEquals(u, r.getAssigned());
	}

	@Test
	public void testGetStatus() {
		Report r = new Report();
		r.setStatus(ReportStatus.OPEN);
		r = FacadeUtil.store(r);
		assertEquals(ReportStatus.OPEN, r.getStatus());
	}

	@Test
	public void testSetStatus() {
		Report r = new Report();
		r.setStatus(ReportStatus.OPEN);
		r = FacadeUtil.store(r);
		assertEquals(ReportStatus.OPEN, r.getStatus());
	}

	@Test
	public void testGetResolution() {
		Report r = new Report();
		r.setResolution(ReportResolution.DUPLICATE);
		r = FacadeUtil.store(r);
		assertEquals(ReportResolution.DUPLICATE, r.getResolution());
	}

	@Test
	public void testSetResolution() {
		Report r = new Report();
		r.setResolution(ReportResolution.DUPLICATE);
		r = FacadeUtil.store(r);
		assertEquals(ReportResolution.DUPLICATE, r.getResolution());
	}

	@Test
	public void testGetOccursIn() {
		ProjectVersion pv = new ProjectVersion();
		pv = FacadeUtil.store(pv);

		Report r = new Report();
		r.setOccursIn(pv);
		r = FacadeUtil.store(r);
		assertEquals(pv, r.getOccursIn());
	}

	@Test
	public void testSetOccursIn() {
		ProjectVersion pv = new ProjectVersion();
		pv = FacadeUtil.store(pv);

		Report r = new Report();
		r.setOccursIn(pv);
		r = FacadeUtil.store(r);
		assertEquals(pv, r.getOccursIn());
	}

	@Test
	public void testGetTimestamp() {
		Report r = new Report();
		Date d = new Date();
		r.setTimestamp(d);
		r = FacadeUtil.store(r);
		assertEquals(d, r.getTimestamp());
	}

	@Test
	public void testSetTimestamp() {
		Report r = new Report();
		Date d = new Date();
		r.setTimestamp(d);
		r = FacadeUtil.store(r);
		assertEquals(d, r.getTimestamp());
	}
}
